import $ from 'jquery'
class RegisterComponent extends React.Component {   
    constructor(props,context){
        super(props,context)

        this.state={
          	password:'',
          	passphone:'',
          	nick:''
        }
    }
    componentWillMount(){

    }
    
  
    
    chkPass(e){
    		e.preventDefault()
			let that = this
	    	let pass= Number($('.inpPass').val())
	    	let phone= Number($('.inpPhone').val())
	    	let nick = $('.reg_id').val()
	    	let str = /^[a-z0-9]{6,16}$/
	    	let str2 =  /^134\d{8}$/
	    	let result =str.test(pass)
	    	let result2 =str2.test(phone)
	    	if(result&&result2){
				that.setState({'password':pass,'passphone':phone,'nick':nick},function(){
					localStorage.setItem('aaa',JSON.stringify(that.state))						
				})
				alert('注册成功')
				$(location).attr('href', '#/log')
    		}else{
    			alert('请按要求填写')
    		}
	    	
	    }
    	

    
    componentDidMount () {

    }

	locaToLogin(){
		$(location).attr('href', '#/log');
	}

    render(){

        return (
        	
            <div className='reg111'>

          		<div className='reg_top' >
          			<a className='reg_log' href='#/'></a>
          			<a className='reg_text' >注册</a>          			
          		</div>
          		
          		<form className='reg_form'>
          			<p><input type='text' placeholder='您的昵称' className='reg_id' /></p>
          			<p><input type='password' className='inpPass' placeholder='您的密码--6 ~ 16个字符' /></p>
          			<p><select>
          				<option>中国大陆</option>
          				<option>香港</option>
          				<option>澳门</option>
          				<option>美国</option>
          			</select></p>
          			<p><input type='text' placeholder='您的手机--134开头' className='inpPhone' /></p>
          			
          			<p><input type='submit' className='active button' value='同意并注册' onClick={this.chkPass.bind(this)} /></p>
          			<p><input type='text' value="登录" className='button' onClick={this.locaToLogin} /></p>
          		</form>
          		
          		
          			    			
          		
          </div>
        )
    }
    
}
//定义默认属性
RegisterComponent.defaultProps={
	
}



export default RegisterComponent